import { prisma } from '@/lib/prisma/client'
import { NextResponse } from 'next/server'

export async function GET() {
  try {
    const executions = await prisma.sceneExecution.findMany({
      take: 10, // 只获取最近10条记录
      orderBy: {
        executedAt: 'desc'
      },
      include: {
        scene: {
          select: {
            name: true
          }
        }
      }
    })

    return NextResponse.json(executions)
  } catch (error) {
    console.error('获取场景执行记录失败:', error)
    return NextResponse.json(
      { error: '获取场景执行记录失败' },
      { status: 500 }
    )
  }
} 